const express = require('express');
const router = express.Router();
const { User } = require('../models');

router.get('/users', async (req, res) => {
  try {
    const user = await User.findOne();
    res.json({ ok: true, data: user ? user.toJSON() : null });
  } catch (err) {
    console.error(err);
    res.status(500).json({ ok: false, error: err.message });
  }
});

module.exports = router;